import time
money=300 #卡余额
commodity=["枕头","吹风机","泡面","毛巾","雨伞"] #商品
commodity_money=[25,88,5,12,20] #对应价钱
cart =[] #购物车
shopping_info=[]  #所买商品
shopping_info_money=[]  #对应的花费
fee=0 #总费用
commodity_num=0 #购买的商品数量
coupon={      #优惠券
    1:"当日枕头9折",
    2:"当日枕头7折",
    3:"当日吹风机8折",
    4:"当日吹风机7折",
    5:"当日吹风机9折",
    6:"当日泡面8折",
    7:"当日毛巾8折",
    8:"当日毛巾6折",
    9:"当日雨伞8折",
    10:"当日雨伞6折"
}
user_coupon=int(input("请选择抽取的优惠券号码(1-10):"))
if 1 <=user_coupon <= 10:
    print("恭喜您，抽中的是：",coupon[user_coupon])
else:
    print("请输入号码1-10")
#时间
local_time=time.localtime()
shopping_time=time.strftime("%Y-%m-%d %H:%M")

choice = input("输入商品(Q或q退出):")
while choice != 'q' and choice !='Q':
    for key1,key2 in zip(commodity,commodity_money):
        if choice == key1:
            if money >= key2:
                if user_coupon in [1, 2] and key1 == "枕头":
                    discount = float(coupon[user_coupon][-2:].replace("折","")) / 10
                    key2 = int(key2 * discount)
                elif user_coupon in [3, 4, 5] and key1 == "吹风机":
                    discount = float(coupon[user_coupon][-2:].replace("折","")) / 10
                    key2 = int(key2 * discount)
                elif user_coupon in [6] and key1 == "泡面":
                    discount = float(coupon[user_coupon][-2:].replace("折","")) / 10
                    key2 = int(key2 * discount)
                elif user_coupon in [ 7, 8] and key1 == "毛巾":
                    discount = float(coupon[user_coupon][-2:].replace("折","")) / 10
                    key2 = int(key2 * discount)
                elif user_coupon in [9, 10] and key1 == "雨伞":
                    discount = float(coupon[user_coupon][-2:].replace("折","")) / 10
                    key2 = int(key2 * discount)
                cart.append(key1)  #加入购物车
                print("当前购物车：",cart)
                hint=input("是否退货YES/NO：")
                if hint =="YES":
                    cart.remove(key1)
                    print("退货成功")
                    choice = input("输入商品(Q或q退出)：")
                    break
                elif hint=="NO":
                    fee += key2
                    money -= key2
                    print("恭喜，购买成功！您的卡余额还剩：",money)
                    commodity_num += 1
                    shopping_info.append(key1)
                    shopping_info_money.append(key2)
                    choice = input("输入商品(Q或q退出)：")
                    break
            else:
                print("穷鬼，钱不够！请到其他超市购买！")
                choice = input("输入商品(Q或q退出)：")
                break
    else:
        print("没有这个商品，别瞎弄！")
        choice = input("输入商品(Q或q退出)：")
if len(shopping_info_money)==0 and len(shopping_info) == 0:
    print("没有购买物品，无购物小票")
else:
    print()
    print("购物小票：\n购物时间：",shopping_time)
    for key3,ke4 in zip(shopping_info,shopping_info_money):
        print(key3,ke4)
    print("购物数量：",commodity_num)
    print("商品总价值：",fee)
    print("卡余额：",money)